<?php

namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\DormRepository;
use App\Models\Dorm;
use App\Validators\DormValidator;

/**
 * Class DormRepositoryEloquent.
 *
 * @package namespace App\Repositories;
 */
class DormRepositoryEloquent extends BaseRepository implements DormRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Dorm::class;
    }

    

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

    protected $fieldSearchable = [
        'code'=>'like',
        'building_id',
        'dorm_type_id',
    ];

    public function batchCreate($arr){
        return $this->model->insert($arr);
    }

    public function batchUpdate(Array $arr,$building_id){
        return $this->model->where('building_id',$building_id)->whereIn('id',$arr['ids'])->update($arr['updateData']);
    }
    
}
